<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<link href="resources/css/cupertino/jquery-ui-1.10.0.custom.css" rel="stylesheet" type="text/css" />
<!-- Include one of jTable styles. -->
<link href="resources/js/jtable/themes/metro/blue/jtable.min.css" rel="stylesheet" type="text/css" />
 <link href="resources/js/jtable/themes/metro/blue/jtable.css" rel="stylesheet" type="text/css" />
  
  <script src="resources/js/jquery-1.9.0.js" ></script>
<script src="resources/js/jquery-ui-1.10.0.custom.min.js" type="text/javascript"></script>

<!-- Include jTable script file. -->
<script src="resources/js/jtable/jquery.jtable.min.js" type="text/javascript"></script>

<title>Carrito</title>
</head>
<body>
<!-- Container for jTable -->
<div id="CarritoTableContainer"></div>
<script type="text/javascript">

    $(document).ready(function () {
 
        //Prepare jtable plugin
        $('#CarritoTableContainer').jtable({
            title: 'Carrito List',
            paging: true,
            sorting: true,
            defaultSorting: 'Name ASC',
            selecting: true, //Enable selecting
            multiselect: true, //Allow multiple selecting
            selectingCheckboxes: true, //Show checkboxes on first column
            //selectOnRowClick: false, //Enable this to only select using checkboxes
            actions: {
                listAction: '/Demo/ProductoList',
                deleteAction: '/Demo/DeleteProducto',
                
                },
            fields: {
                Id: {
                    key: true,
                    create: false,
                    edit: false,
                    list: false
                },
                Producto: {
                    title: 'producto',
                    width: '23%',
                    inputClass: 'validate[required]'
                },
                Cantidad: {
                    title: 'Cantidad',
                    width: '13%',
                    inputClass: 'validate[required]'
                },
                Costo: {
                    title: 'Costo',
                    width: '12%',
                    inputClass: 'validate[required]'
                },
                Existencia: {
                    title: 'Existencia',
                    width: '12%',
                    values: { 'false': 'Inexistente', 'true': 'Existente' },
                    defaultValue: 'true'
                },
               
            },
            //Register to selectionChanged event to hanlde events
            selectionChanged: function () {
                //Get all selected rows
                var $selectedRows = $('#CarritoTableContainer').jtable('selectedRows');
 
                $('#SelectedRowList').empty();
                if ($selectedRows.length > 0) {
                    //Show selected rows
                    $selectedRows.each(function () {
                        var record = $(this).data('record');
                        $('#SelectedRowList').append(
                            '<b>StudentId</b>: ' + record.StudentId +
                            '<br /><b>Name</b>:' + record.Name + '<br /><br />'
                            );
                    });
                } else {
                	
                	
                    //No rows selected
                    $('#SelectedRowList').append('No row selected! Select rows to see here...');
                }
            },
            rowInserted: function (event, data) {
                if (data.record.Name.indexOf('Andrew') >= 0) {
                    $('#CarritoTableContainer').jtable('selectRows', data.row);
                }
            }
        });
 
       
        //Delete selected students
        $('#DeleteAllButton').button().click(function () {
            var $selectedRows = $('#CarritoTableContainer').jtable('selectedRows');
            $('#CarritoTableContainer').jtable('deleteRows', $selectedRows);
            
        });
    });

</script>


</body>
</html>